﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Entity.Car_Rental.Product>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Create
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        产品管理－添加/修改产品</h2>
    <% using (Html.BeginForm())
       {%>
    <%: Html.ValidationSummary(true) %>
    <%: Html.HiddenFor(model => model.ProductID) %>
    <fieldset>
        <div class="editor-label">
            名称：
        </div>
        <div class="editor-field">
            <%: Html.TextBoxFor(model => model.ProductName) %>
            <%: Html.ValidationMessageFor(model => model.ProductName) %>
        </div>
       <%-- <div class="editor-label">
            分类：
        </div>
        <div class="editor-field">
            <%: Html.CategoryForSelectList(Model==null?0:Model.CategoryID) %>
        </div>--%>
        <div class="editor-label">
            市场价格：
        </div>
        <div class="editor-field">
            <%: Html.TextBoxFor(model => model.MarketPrice, new {style="width:50px;"})%>￥
            <%: Html.ValidationMessageFor(model => model.MarketPrice) %>
        </div>
        <div class="editor-label">
            销售价格
        </div>
        <div class="editor-field">
            <%: Html.TextBoxFor(model => model.RealPrice, new { style = "width:50px;" })%>￥
            <%: Html.ValidationMessageFor(model => model.RealPrice) %>
        </div>
        <div class="editor-label">
            打折：
        </div>
        <div class="editor-field">
            <%: Html.TextBoxFor(model => model.Discount ,new { style = "width:50px;" }) %>
            <%: Html.ValidationMessageFor(model => model.Discount) %>（100为不打折，90为9折，以此类推）
        </div>
        <div class="editor-label">
            库存：
        </div>
        <div class="editor-field">
            <%: Html.TextBoxFor(model => model.ProductCount, new { style = "width:50px;" })%>
            <%: Html.ValidationMessageFor(model => model.ProductCount) %>（订出车后，库存减1，车辆返还后，库存加1）
        </div>
        <div class="editor-label">
            图像：
        </div>
        <div class="editor-field">
            <img id="headpic" class="seller_t2" src="" width="80" height="80" style="display: none" />
            <input type="hidden" id="Image" name="Image" value="" />
            <iframe src='<%=Url.Action("uploadheadpic","system") %>' scrolling="no" id='Iframe1'
                style="width: 355px; height: 22px" frameborder="0"></iframe>
        </div>
        <div class="editor-label">
            描述：
        </div>
        <div class="editor-field">
            <%: Html.TextAreaFor(model => model.Info, new { rows = "16", cols = "100", @class = "xheditor" })%>
            <%: Html.ValidationMessageFor(model => model.Info) %>
        </div>
    <%--    <div class="editor-label">
            属性：
        </div>
        <div class="editor-field" id="propertylist">
            <%: Html.PropertyType_PropertyForPanel()%><input type="button" id="add" class="button"
                value="添加属性" />
        </div>
        <div class="editor-label">
            选择的属性：
        </div>
        <div class="editor-field" id="sel">
            <%if (Model != null)
              {
                  if (Model.Product_Property_R_Extend != null && Model.Product_Property_R_Extend.Count() > 0)
                  {
                      foreach (var item in Model.Product_Property_R_Extend.ToList())
                      {
            %>
            <span style='display: block' id='row<%=item.ProductPropertyID %>'>
                <%=item.ProductProperty_Extend.PropertyName%>
                <input type='hidden' name='selList' value='<% =item.ProductPropertyID%>' />&nbsp;&nbsp;
                <a href='javascript:removeRow("<%=item.ProductPropertyID %>")'>[移除]</a></span>
            <%}
                  }
              } %>
        </div>--%>
       
        <p class="button-span">
            <%=Html.CreateButton(Common.Background.Entity.UserOperatorRole.ModifyEvent | Common.Background.Entity.UserOperatorRole.AddEvent)%>
        </p>
   
    </fieldset>
    <% } %>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
    <script type="text/javascript">
        function removeRow(id) {
            $("#row" + id).remove();
        }
        $(function () {

            $("#add").click(function () {
                var sel = "";
                $.each($("#propertylist").find("input[type=checkbox][checked=true]"), function (i, o) {
                    if ($("#sel").find("span[id$='" + $(o).val() + "']").size() == 0)//不把重复的记录加到表格行中
                    {
                        sel = $(o).next("Label").text();
                        if ($(o).next("Label").text() == "")
                            sel = $(o).next("font").find("Label").first().text();
                        $("#sel").append("<span style='display:block' id='row" + $(o).val() + "'>" + sel + "<input type='hidden' name='selList' value='" + $(o).val() + "'>&nbsp;&nbsp;<a href=javascript:removeRow(" + $(o).val() + ")>[移除]</a></span>");
                    }
                })
            });
        });


        /* 控制子页面的图像 */
        function hideLoading() {
            $('#Iframe1').show();
        }
        function showLoading() {
            $('#Iframe1').hide();
        }
        function changePic(data) {
            if (data.result == true) {
                $('#Image').val(data.msg);
                $("#headpic").show();
                $("#headpic").attr('src', data.msg);
            }
            else {
                alert(data.msg);
            }
        }



    </script>
</asp:Content>
